1 Before the Installation

1.1 Download Debian Image

Debian provides many options for installation.

For the convenience, we will download [DVD version: debian-8.2.0-amd64-DVD-1.iso][DVD] in this manual.

1.2 Prepare Device for Booting

After downloading the CD/DVD image, you need to write them directly to an USB stick or a CD/DVD.

1.2.1 Create a bootable CD/DVD

Create a bootable CD/DVD is as easy as burning your favorite movie into your DVD. Almost all modern operation systems have som built-in disc burner. To create your own bootable device, follow the approaches below:

Finally, your CD/DVD turns into a “bootable device”.

1.2.2 Create a bootable USB driver

If you do not have any blank CD at hand, you can use an USB stick as a bootable device.

  1. Download UNetbootin.
  2. Start UNetbootin and select the installation diskimage you’ve downloaded.
  3. Select Type as USB Drive
  4. Select Drive as where your USB stick mounted.
  5. Click OK.

After the process completes, you will get a reusable bootable USB stick.

1.3 Set the BIOS Booting Priority

BIOS is a built-in firmware to perform hardware initialization during startup on PC. One of its main functions is to select which devices are potential bootable devices, and in which order booting from them will be attempted. Thus, you should configure your bootable device first for the boot priority.

  1. A modern BIOS setup utility can accessed by pressing a certain key on the keyboard when the PC starts. Usually the key is advertised for short time during the early startup, for example “Press F2 for Setup Menu.”.

  1. Then switch to Boot tab.

  1. Select your bootable USB stick as 1st Boot Device.

Once your computer restarts, it will boot using your new boot order priority.

NOTE: While different computers use different BIOS keys and have different BIOS layouts, the process is similar on most computers.

2 Install Debian

2.1 Install Debian Operation System

Here comes the most important part of this manual. Assumed you already booted your machine via the bootable device. You will enter the install welcome page, we will choose normal Install mode:

2.1.1 Setup Location, Locales and Keyboard Layout

It is important to ensure your system time, keyboard layout is correct during the installation.
In this manual, we choose:

  • system language: English
  • location: Other/Asia/Taiwan
  • locale: en_US.UTF-8
  • keyboard: American English

2.1.2 Setup Hostname and Account

  1. Enter the hostname for your server. (the domain name is often left blank)

  1. Leave blank for the password of root user. (We use sudo user istead.)

  1. Setup your sudo user’s name and password.

2.1.3 Thing about Partition

The design of partition table varies cases by cases. Assumed that you are going to setup a server for R computing. You want to mix a 5 TB HDD and a 1 GB SSD for these two aims:

  • Speed up your system: as much commonly used data as possible stays on the SSD.
  • Keep volatile data off the SSD to reduce wear.

A scheme would be like this:

  • SSD: /boot, / (root), /usr
  • HDD: /var, /home, /tmp, swap

The recommended size of the partitions:

  • /boot : 200 - 500 MB For store multiple kernels/boot images, around 350 MB of partition size is sufficient.
  • / (root) : > 20 GB Traditionally, / (root) contains the [/usr][/usr] directory, which can grow significantly depending on how much softwares installed (softwares installed in /usr usually be shared among all users.)

  • /var : 8-12 GB This partition may contain mails, cache, and other user programs and daemon. Seperate it from / (root) can reduce danger and wear of your SDD.

  • /tmp: > 2 GB This partition stored temporary files. For instance, your downloaded a Debian DVD image via Firefix with open option. It would download to /tmp. If you are going to do simulation with lots of temporary output files, you can save them inside /tmp. The recommanded size is not less 2 GB.

  • swap : [varies] Swap area is so called virtual memory. The old general rule for swap partition size was to allocate twice the amount of physical RAM. If a sufficient amount of your physical RAM is available, it is possible to have a smaller partition size of swap area.

  • /home : [varies] It is typically where user data, downloads, and multimedia reside. On a desktop system, /home is typically the largest filesystem on the drive.

Finally, your partition table would look like this:

  SCSI1 (0,0,0) (sda) - 1.0 GB VBOX VIRTUAL SSD
        #1 primary  500.0 MB  B  f  ext4  /boot
        #2 primary    5.0 GB     f  ext4  / 
        #5 logical  100.0 GB     f  ext4  /usr

  SCSI2 (1,0,0) (sdb) - 5.0 TB VBOX HARDDISK GPT
        #1 primary   12.0 GB     f  ext4  /var
        #2 primary  100.0 GB     f  swap  swap
        #3 primary   15.0 GB     f  ext4  /tmp
        #4 primary    4.0 TB     f  ext4  /home
        #5            0.8 TB        FREE SPACE

2.1.4 Setup Partition

  1. Manual partition disks. Select which disk to be parted.

  1. Create new partition table. (Default: MBR)
    NOTE: When your disk volume exceed 2 TB, you should choose GPT instead of default MBR

  1. Select Free Space to create new partition.

  1. Setup size, type and location of new partition. Should create /boot first for setting bootloader.

  1. Turn on bootflag for /boot partition. Then write changes to disks.

2.1.5 Skip the Configuration of Package Manager

A well developed Package Manager can be the soul of a linux distribution, bring much convenience to download open-source software in minimum typing strokes. However, we will config our package manager later. 1. Skip scanning another CD/DVD and network installation.

  1. Decide participate Debian survey or not. (We choose no.)

  1. Select only standard system utilties to install.

2.1.6 Install the GRUB Boot Loader into MBR

By default, the amd64 boot loader “grub” will be installed into the Master Boot Record (MBR), where it will take over complete control of the boot process.

  1. Select Enter device manually.

  1. Decide where to install GRUB boot loader. (Generally, it depends on where your /boot partition located. In this manual, you should input /dev/sda/.)

  1. Finished the installation.

  1. Congratulations! You’ve done the most difficult part of this manual. Let’s startup the server.

2.2 Configure the “APT” Package manager

2.2.1 Check The Network Connection

Although you’ve succeed the installation, you cannot do anything without configuring your source of your package manager.

Most Debian-based systems provied a powerful package manager called Advanced Packaging Tool, or APT. We can easily use apt-get command to install/remove open-source software in the Debian repository.

Before starting the configuraion, check the network connection in advance:

ping www.gooogle.com

If you receive something like, it mean your connection is well:

PING www.google.com (74.125.203.105) 56(84) bytes of data.
64 bytes from th-in-f105.1e100.net (74.125.203.105): icmp_seq=1 ttl=46 time=15.6 ms
64 bytes from th-in-f105.1e100.net (74.125.203.105): icmp_seq=2 ttl=46 time=15.4 ms
64 bytes from th-in-f105.1e100.net (74.125.203.105): icmp_seq=3 ttl=46 time=15.6 ms

2.2.2 Setup Archive Mirror Repository to Your Server

  1. Open /etc/apt/source.list We will use vi to edit source.list. If you are not familiar to vi, use nano to substitube for vi in the command.

    sudo vi /etc/apt/source.list
  2. For an archieve mirror of Debian 8 (jessie) repository, simply add following lines into sourece.list.

    deb http://<favourite-debian-mirror>/debian/ jessie main
    deb-src http://<favourite-debian-mirror>/debian/ jessie main

    NOTE: You need to substitute <favourite-cran-mirror> by one of the mirror URLs listed in the mirror list. For example: deb http://debian.csie.ntu.edu.tw/debian/ jessie main

  3. Comment out the sources from CD/DVD In the source.list file, there are some CD/DVD sources reserved for dealing some situation without network in the future. For now, they are useless and should be commented out:

    # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie contrib main
    # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie contrib main

After all the commands above, you can install whatever your want in the Debian Repository.

2.2.3 Let’s learn some useful apt-get command:

  • apt-get update: This command can resynchronize and update all packages from the sources. For security issue, ensure you update your server regulariry.
  • apt-get install/remove: These command can simply install/remove packages you specified.
  • apt-get auroremove: After you remove some pakcages, you may want to execute this command for clean all the dependency.

2.3 Optional: Install Graphical User Desktop Environment

If you are not comfortable with command line interface, you can download your favorite desktop environment such as Gnome or KDE from the Debian repository. Following are some commands to install them.

2.3.1 Gnome Desktop Environment (GDM)

The GNOME Desktop Enviroment is an fantastic-looking, modern, and useful desktop environment. GNOME is both free and one of the most widely used desktop environments on the GNU/Linux operating system.

To install it, first make sure that tasksel and aptitude are installed:

sudo apt-get install aptitude tasksel

Then, install the GNOME task:

sudo tasksel install gnome-desktop --new-install

2.3.2 LXDE (Lightweight X11 Desktop Environment)

LXDE is a free desktop environment with comparatively low resource requirements. It is recommanded if you only need basic operation with graphical interface.
To install a complete Debian LXDE desktop environment, execute commands below:

sudo apt-get update
sudo apt-get install task-lxde-desktop

2.3.3 Start X-session

After the installation, you can simply enter the desktop environment by execute the command:

startx

NOTE: Click here for more desktop environment installation guide.

3 Softwares Installation and Other Configuration

3.1 Useful Softwares and Services

Before starting any simulations or programming, you need to install the following software:

  • Vim: a powerful text editor.
  • R: a open source, multi-platfrom language and environment for statistical computing and graphics.
  • openssh: premier connectivity tool for remote login with the SSH protocol.
  • Rstudio Server: a powerful and productive user interface for R. Also free, open-source, and cross-paltform.

While any package would have been tested thoroughly before included in a Debian stable release, the latest version of R and other packages won’t be included in the repository. Hence, you need to add some additional repositories manually.

The following steps are all done in command line (or terminal emulator).

3.2 Vim

sudo apt-get update
sudo apt-get install vim

3.3 R

For downloading latest version of R, adding additional repositories to debian repository list is required.

  1. For a backport of latest R to Debian 8 (jessie), simply open /etc/apt/sourece.list.

    sudo vim /etc/apt/source.list

    Then add following lines into /etc/apt/sourece.list.

    deb http://<favourite-cran-mirror>/bin/linux/debian jessie-cran3/
    deb-src http://<favourite-cran-mirror>/bin/linux/debian jessie-cran3/

    NOTE: You need to substitute <favourite-cran-mirror> by one of the mirror URLs listed in the mirror list.
    For example: deb http://cran.csie.ntu.edu.tw/bin/linux/debian jessie-cran3/.

  2. Fetch and import Debian backports archives on CRAN (CRAN Debian archive) with key ID 381BA480.

    sudo apt-key adv --keyserver keys.gnupg.net --recv-key 381BA480
  3. Finally, install R.

    sudo apt-get update
    sudo apt-get install r-base r-base-dev
  4. After the installation, execute this command to check the version of R in your server is up-to-date.

    R --version

3.4 OpenSSH

3.4.1 Installation

Normally the client and server are installed by default. If not it suffices to run:

sudo apt-get update
sudo apt-get install openssh-client openssh-server

3.4.2 Simple Configuration

The main configuration files are in the directory /etc/ssh:

  • ssh_config : client configuration file
  • sshd_config : server configuration file

We will only cover the server configuration in this manual.

  1. Open /ect/ssh/sshd_config for editing.

    sudo vim /etc/ssh/sshd_config
  2. For security, change the listening port instead of default TCP port 22 as such:

    Port 10022
  3. Ensure that PermitRootLogin is set to no in sshd_config (we use sudo-user only):

    PermitRootLogin no
  4. Start your SSH service.

    sudo /etc/init.d/ssh start
  5. Note that after any configuration, always restart server to apply your changes.

    sudo /etc/init.d/ssh restart

3.5 Rstudio Server

RStudio: a integrated development environment (IDE) for R. Also free, open source and multi-platform. To start/stop/restart Rstudio server, use followings commands:

3.5.1 Installation

To download and install RStudio Server. Execute the following commands. Note that gdebi should be installed first.

sudo apt-get update
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/rstudio-server-0.99.491-amd64.deb
sudo gdebi rstudio-server-0.99.491-amd64.deb

To verify your installation, excute following command:

sudo rstudio-server verify-installation

3.5.2 Simple Configuration

sudo rstudio-server stop
sudo rstudio-server start
sudo rstudio-server restart

The default port for Rstudio server is 8787. That means any can connect to the server through the URL http://:8787.
If you wish to change to another port, you should add following configuration into /etc/rstudio/rserver.conf file. For example:

www-port=18787

Note that after any configuration, always restart server to apply your changes.

sudo rstudio-server restart

Other tips: - The users in Rstudio server are references to users of system. - Each user needs to be created with a home directory. - More tips on Rstudio server support.

3.6 Port Forwarding / Port Mapping

To forward ports, you first need to understand about what your router does.

Your router has a function called Network Address Translation, or NAT, built-in. Inside your network, computers get their own addresses like 192.168.1.100. These addresses are called “private” or “reserved” addresses which automatically assigned by your home router via DHCP. A computers can communicate with router and with each other via its own address.

However, these “private” addresses could only be recognized within private network. It will be failed if others want to connect to a specific computer via an address like 192.163.1.100. Therefore, we should change it from the private IP of the computer to the public IP of the router. This is so called the port forwarding.

3.6.1 Configure Port Forwarding on a Router

Configuration of port forwarding often varies from routers to routers. In this munual, we would use D-Link for demonstration.

  1. Use your favorite browser to visit “192.168.0.1” to connect to your D-Link router.

  1. Select Network Setting at the sidebar. Then scroll to Add New DHCP Reservation.

  1. Add a new DHCP reservation for your server’s IP. Remember to save your configuration.

  1. Wait for seconds. Then Select Advance Setting at the top bar. Select Virtual Server at the siderbar.

  1. Add virtual server.
    1. Add a new application named SSH. Set Public port at what you set in sshd_config. (We use 10022 for demo.)
      NOTE: Your can also set a port for private network
    2. Select the machine/server your want to forward the port. (Or just type its private IP)
      NOTE: Remember to save your changes

NOTE: Connecting to your Rstudio server via TCP/IP is exactly the same thing as connecting to your SSH server. The only thing need to change is the port you forwarding. (Default port of Rstudio server is 8787.)